package com.ims.core.doc.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ims.common.annotation.Log;
import com.ims.common.core.controller.BaseController;
import com.ims.common.core.domain.AjaxResult;
import com.ims.common.enums.BusinessType;
import com.ims.core.doc.domain.TInInvoice51;
import com.ims.core.doc.service.ITInInvoice51Service;
import com.ims.common.utils.poi.ExcelUtil;
import com.ims.common.core.page.TableDataInfo;

/**
 * 51 数电发票（铁路电子客票）Controller
 *
 * @author IMS
 * @date 2024-11-25
 */
@RestController
@RequestMapping("/doc/tieludianzi")
public class TInInvoice51Controller extends BaseController
{
    @Autowired
    private ITInInvoice51Service tInInvoice51Service;

    /**
     * 查询51 数电发票（铁路电子客票）列表
     */
    @PreAuthorize("@ss.hasPermi('doc:tieludianzi:list')")
    @GetMapping("/list")
    public TableDataInfo list(TInInvoice51 tInInvoice51)
    {
        startPage();
        List<TInInvoice51> list = tInInvoice51Service.selectTInInvoice51List(tInInvoice51);
        return getDataTable(list);
    }

    /**
     * 导出51 数电发票（铁路电子客票）列表
     */
    @PreAuthorize("@ss.hasPermi('doc:tieludianzi:export')")
    @Log(title = "51 数电发票（铁路电子客票）", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TInInvoice51 tInInvoice51)
    {
        List<TInInvoice51> list = tInInvoice51Service.selectTInInvoice51List(tInInvoice51);
        ExcelUtil<TInInvoice51> util = new ExcelUtil<TInInvoice51>(TInInvoice51.class);
        util.exportExcel(response, list, "51 数电发票（铁路电子客票）数据");
    }

    /**
     * 获取51 数电发票（铁路电子客票）详细信息
     */
    @PreAuthorize("@ss.hasPermi('doc:tieludianzi:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tInInvoice51Service.selectTInInvoice51ById(id));
    }

    /**
     * 新增51 数电发票（铁路电子客票）
     */
    @PreAuthorize("@ss.hasPermi('doc:tieludianzi:add')")
    @Log(title = "51 数电发票（铁路电子客票）", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TInInvoice51 tInInvoice51)
    {
        return toAjax(tInInvoice51Service.insertTInInvoice51(tInInvoice51));
    }

    /**
     * 修改51 数电发票（铁路电子客票）
     */
    @PreAuthorize("@ss.hasPermi('doc:tieludianzi:edit')")
    @Log(title = "51 数电发票（铁路电子客票）", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TInInvoice51 tInInvoice51)
    {
        return toAjax(tInInvoice51Service.updateTInInvoice51(tInInvoice51));
    }

    /**
     * 删除51 数电发票（铁路电子客票）
     */
    @PreAuthorize("@ss.hasPermi('doc:tieludianzi:remove')")
    @Log(title = "51 数电发票（铁路电子客票）", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tInInvoice51Service.deleteTInInvoice51ByIds(ids));
    }
}
